class Solution {
public:
//排序，将排序后的字符串数组作哈希
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ret;
        vector<string> strs_bak = strs;
        unordered_map<string, vector<string>> hash;
        for (int i = 0; i < strs.size(); i++)
        {
            sort(strs[i].begin(), strs[i].end());
            hash[strs[i]].push_back(strs_bak[i]);
        }

        for (auto it : hash)
        {
            ret.push_back(it.second);
        }

        return ret;
    }
};